BLOCK.Model = "models/props_lab/blastdoor001b.mdl";
BLOCK.BlockName = "Force Door";
BLOCK.Desc = "Only set teams may way through";
BLOCK.Health = 300;
BLOCK.HackTime = 15;
BLOCK.HackDuration = 30;

function BLOCK:Init()
	self.SENT.Entity:SetMaterial("effects/com_shield002a");
	if(SERVER) then
		self.SENT.Entity:SetTrigger(true);
		self.SENT.Entity:SetCollisionGroup(COLLISION_GROUP_WORLD);
		self:ConVar("ratio", 3);
	end
	self.hackTeam = -1;
end

function BLOCK:ValidPos( vec, err, ply )
	local blocks = ents.FindInSphere(vec, 150);
	
	for key, val in pairs(blocks) do
		if(val:GetClass() == "bh_block" || val:GetClass() == "bh_builder") then
			if(val.blockName == "door") then 
					if(err) then hook.Call("ShowNotice", nil, "Doors cannot be places so close together", ply);
					end
				return false; 
			end
		end
	end
	return true;
end

function BLOCK:Touch(ent)
	local t;
	if(self.hackTeam != -1) then t = self.hackTeam;
	else t = self.Team;
	end
	if(ent:IsPlayer() && ent:Team() == t) then return; end
	ent:SetLocalVelocity(ent:GetVelocity()*-3);
end

function BLOCK:Hack(ply)
	self.hackTeam = ply:Team();
end

function BLOCK:EndHack()
	self.hackTeam = self.Team;
end